const fs = require('fs')
const http = require('http')
const path = require('path')
const path1 = path.join(__dirname, './book.txt')
const server = http.createServer((req, res) => {
  console.log(req, '---- req ---')

  if (req.method === 'GET') {
    const readStream = fs.createReadStream(path1)
    readStream.pipe(res)
    res.setHeader('Content-Type', 'text/plain;charset=utf-8')
  }
})
server.listen(8088, () => {
  console.log('服务器启动成功 in 8000 port')
})
